package com.zc.zby.basicframedemo.activity;

import android.os.Bundle;

import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
import com.zc.zby.basicframedemo.R;
import com.zc.zby.basicframedemo.base.BaseActivity;
import com.zc.zby.basicframedemo.data.DataUtils;
import com.zc.zby.basicframedemo.weight.GlideImageLoader;

import java.util.Arrays;
import java.util.List;

import butterknife.BindView;

public class BannerActivity extends BaseActivity {

    @BindView(R.id.banner1)
    protected Banner mBanner1;
    @BindView(R.id.banner2)
    protected Banner mBanner2;
    @BindView(R.id.banner3)
    protected Banner mBanner3;
    private String[] images = {"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1537878490501&di=d166cef4a5e2b592efb3b051ce370f99&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F017e7f58956237a801219c77ac5170.jpg%401280w_1l_2o_100sh.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1537878490501&di=b80cb7b466f2d88eb513932fd091eee3&imgtype=0&src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20170809%2F5832efa431eb49d29a798f7f947c426c_th.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1537878523320&di=18cf251391ee3f112039fa960d52e2e0&imgtype=0&src=http%3A%2F%2Fwww.dogmr.com%2Fuploads%2Fallimg%2F150122%2F1-15012213264c49.jpg",
            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1537878523320&di=2545282a87d21472fbe19a34504931ac&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimage%2Fc0%253Dshijue1%252C0%252C0%252C294%252C40%2Fsign%3D03c021e7dd2a6059461de959405d5eee%2F242dd42a2834349b51f4a3abc3ea15ce36d3be2a.jpg"};


    @Override
    public int getLayoutId() {
        return R.layout.activity_banner;
    }

    @Override
    public void initViews(Bundle savedInstanceState) {
        initBanner1();
        initBanner2();
        initBanner3();
    }

    private void initBanner3() {
        // 设置图片加载器
        mBanner3.setImageLoader(new GlideImageLoader());
        // 设置图片集合
        mBanner3.setImages(Arrays.asList(images));
        // 设置轮播时间
        mBanner3.setDelayTime(2000);
        mBanner3.setBannerAnimation(Transformer.CubeIn);
        // banner设置方法全部调用完毕时最后调用
        mBanner3.start();
    }

    private void initBanner2() {
        // 设置图片加载器
        mBanner2.setImageLoader(new GlideImageLoader());
        // 设置图片集合
        mBanner2.setImages(Arrays.asList(images));
        mBanner2.setBannerTitles(Arrays.asList(DataUtils.titles));
        mBanner2.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
        // 设置轮播时间
        mBanner2.setDelayTime(2000);
        mBanner2.setBannerAnimation(Transformer.Accordion);
        // banner设置方法全部调用完毕时最后调用
        mBanner2.start();
    }

    private void initBanner1() {
        // 设置图片加载器
        mBanner1.setImageLoader(new GlideImageLoader());
        mBanner1.setIndicatorGravity(BannerConfig.RIGHT);
        // 设置图片集合
        mBanner1.setImages(Arrays.asList(images));
        // 设置轮播时间
        mBanner1.setDelayTime(2000);
        mBanner1.setBannerAnimation(Transformer.RotateDown);
        // banner设置方法全部调用完毕时最后调用
        mBanner1.start();
    }

    @Override
    public void setListeners() {

    }

    @Override
    public void initToolBar() {
        getToolbarTitle().setText("Banner轮播图");
    }

    @Override
    public void initData() {

    }
}
